package com.oa.co.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oa.co.mapper.GoodsMapper;
import com.oa.co.pojo.Goods;
import com.oa.co.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;


    @Override
    public PageInfo<Goods> getPageData(Integer pageNum, Integer size, Integer goods_id, String goods_name) {
        Goods goods = new Goods();
        goods.setGoods_id(goods_id);
        goods.setGoods_name(goods_name);
        //传入  页码  和  每页记录数

        PageHelper.startPage(pageNum,size);

        List<Goods> goodses =  goodsMapper.findGoodsByCondition(goods);
        //把查询结果封装在 pageInfo 对象中  这个对象就是之前 咱们自己封装的 Page  里面有 分页信息 可以点进去看下
        PageInfo<Goods> page = new PageInfo<>(goodses);

        return page;

    }
}
